﻿@model Tasks.UI.Models.Account.PersonalMemberEditModel 
@{
    ViewBag.Title = "EditPersonalMember";
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>编辑个人会员信息</title>
    <link href="@Config.GetCssResourcePath("main.css")" rel="stylesheet" type="text/css" />
    <link href="@Config.GetCssResourcePath("table.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/themes/base/jquery.ui.all.css")" rel="stylesheet" type="text/css" />
    <script src="@Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery-ui-1.8.11.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.validate.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.combobox.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/global.js")" type="text/javascript"></script>
    <script type="text/javascript">
        $(document).ready(function () {

            // 手机号码验证
            jQuery.validator.addMethod("isMobile", function (value, element) {
                var length = value.length;
                return this.optional(element) || (length == 11 && /^(((13[0-9]{1})|(15[0-9]{1})|(18[0-9]{1}))+\d{8})$/.test(value));
            }, "请正确填写您的手机号码");

            // 身份证号码验证
            jQuery.validator.addMethod("isIdCardNo", function (value, element) {
                var length = value.length;
                return this.optional(element) || (length == 18 && /^(\d{14}|\d{17})(\d|[xX])$/.test(value));
            }, "请正确输入您的身份证号码");

            // 邮政编码验证
            jQuery.validator.addMethod("isZipCode", function (value, element) {
                var tel = /^[0-9]{6}$/;
                return this.optional(element) || (tel.test(value));
            }, "请正确填写您的邮政编码");

            // 中文字两个字节
            jQuery.validator.addMethod("byteRangeLength", function (value, element) {
                var length = value.length;
                for (var i = 0; i < value.length; i++) {
                    if (value.charCodeAt(i) > 127) {
                        length++;
                    }
                }
                return this.optional(element) || (length >= 3);
            }, "请确保输入的值在3-15个字节之间(一个中文字算2个字节)");

            // 字符验证
            jQuery.validator.addMethod("userName", function (value, element) {
                return this.optional(element) || /^[\u0391-\uFFE5\w]+$/.test(value);
            }, "用户名只能包括中文字、英文字母、数字和下划线");



            $("#form").validate({
                rules: {
                    AccountNo: {
                        required: true
                    },

                    Name: {
                        required: true,
                        userName: true,
                        byteRangeLength: true
                    },
                    MobileNo: {
                        required: true,
                        isMobile: true
                    },
                    IDCard: {
                        isIdCardNo: true
                    },
                    EMail: {
                        email: true
                    },
                    PostalCode: {
                        isZipCode: true
                    }
                },

                messages: {
                    AccountNo: {
                        required: "请输入账号"
                    },
                    Name: {
                        required: "请填写用户名",
                        byteRangeLength: "用户名必须在3-15个字符之间(一个中文字算2个字符)"
                    },
                    MobileNo: { required: "请填写手机号码",
                        isMobile: "请正确填写您的手机号码"
                    },
                    EMail: {
                        email: "请输入一个有效的EMail地址"
                    }
                },
                success: function (label) {
                    label.html("<img src='../../Images/accept.png'/>");
                },
                /* 获得焦点时不验证 */
                focusInvalid: false,
                onkeyup: false
            });
        });

        //init
        $(function () {
            $.ctrl.employeeDropdownList("SalesmanIDName", "SalesmanID"); //绑定业务员下拉框
            $.ctrl.employeeDropdownList("CustomerServiceIDName", "CustomerServiceID"); //绑定员工下拉框
            $("#CategoryName").combobox({
                ColumnsMapsNodeName: 'ID|Name',
                TagObject: null,
                MustMatching: false,
                ListWidth: 250,
                DisplayHead: true,
                ListType: ListType.Combobox,
                DataType: DataType.Xml,
                DataLoadOnce: false,
                RemoteUrl: "/data/getxmldata?datatype=cats&keyword=",
                TextFormat: 'V1',
                ValueFormat: 'V0,V1',
                OnItemClickEvent: function (src, data) {
                    var arrmp = data.value.split(",");
                    $("#CategoryID").attr("value", arrmp[0]);
                    $("#CategoryName").attr("value", arrmp[1]);
                },
                HeadColumn: [
            { name: "编号", width: 60 },
            { name: "类别名称" }
            ],
                KeyWordColumn: '',
                Buttons: [
            { text: "添加", event: function () { parent.showModalDialog('/Dict/Manage?dictKey=PER_MEMBER_CAT', false); } }
            ]
            });
            $("#SourceName").combobox({
                ColumnsMapsNodeName: 'ID|Name',
                TagObject: null,
                MustMatching: false,
                ListWidth: 250,
                DisplayHead: true,
                ListType: ListType.Combobox,
                DataType: DataType.Xml,
                DataLoadOnce: false,
                RemoteUrl: "/data/getxmldata?datatype=source&keyword=",
                TextFormat: 'V1',
                ValueFormat: 'V0,V1',
                OnItemClickEvent: function (src, data) {
                    var arrmp = data.value.split(",");
                    $("#SourceID").attr("value", arrmp[0]);
                    $("#SourceName").attr("value", arrmp[1]);
                },
                HeadColumn: [
            { name: "编号", width: 60 },
            { name: "名称" }
            ],
                KeyWordColumn: '',
                Buttons: [
            { text: "添加", event: function () { parent.showModalDialog('/Dict/Manage?dictKey=PER_MEMBER_SOURCE', false); } }
            ]
            });
            initProvince("#ProvinceID");
            initCity("#CityID");
            datePicker("#Birthday");
        })

    </script>
</head>
<body>
    <form action="EditPersonalMember" id="form" method="post">
    <div id="container">
        <input id="UserID" name="UserID" type="hidden" value="@Model.UserID" />
        <div class="navTitle">
            <ul>
                <li class="Home SecondLast"><a href="#">
                    <div class="HomeIcon">
                    </div>
                    <font><font>Home</font></font></a></li><li class="Last"><span><font><font>编辑个人会员</font></font></span></li>
            </ul>
        </div>
          <h1>
                <font>编辑个人会员</font></a>
            </h1>
        <p class="intro">
            <font>录入会员的基本信息，点击“保存”按钮保存资料。 </font>
        </p>
        @Html.OutputMessage(Model.Message, Model.MessageType)
        <div id="horizontal">
            <table>
                <tr>
                    <td style="width: 100px;">
                        &nbsp姓&nbsp&nbsp名&nbsp：
                    </td>
                    <td>@Html.TextBoxFor(a => a.Name)
                    </td>
                </tr>
                <tr>
                    <td>
                        &nbsp账&nbsp&nbsp号&nbsp：
                    </td>
                    <td>@Html.TextBoxFor(a => a.AccountNo)
                        <b class="b">
                            @Model.error
                        </b>
                    </td>
                </tr>
                <tr>
                    <td>
                       &nbsp性&nbsp&nbsp别&nbsp：
                    </td>
                    <td>
                        @Html.DropDownListFor(a => a.Sex, PageHelper.SexSelector(Model.Sex), new { style = "width:60px" })
                    </td>
                </tr>
                @if (@Model.UserID == 0)
                {
                    <tr>
                        <td>
                            &nbsp密&nbsp&nbsp码&nbsp：
                        </td>
                        <td>@Html.PasswordFor(a => a.Password, new { style = "width:100px" }) <b class="b">@Model.PasswordError</b>
                        </td>
                    </tr>
                }
                <tr>
                    <td>
                       &nbsp生&nbsp&nbsp日&nbsp：
                    </td>
                    <td>
                        @Html.TextBoxFor(a => a.Birthday, new { @readonly = "true" })
                    </td>
                    @Html.HiddenFor(t => t.CategoryID)
                    @Html.HiddenFor(t => t.CategoryName)
                    <tr>
                        <td>
                            客户来源：
                        </td>
                        <td>
                            @Html.HiddenFor(t => t.SourceID)
                            @Html.TextBoxFor(t => t.SourceName)
                        </td>
                    </tr>
                    <tr>
                        <td>
                            手机号码：
                        </td>
                        <td>@Html.TextBoxFor(a => a.MobileNo)
                            <b class="b">
                                @Model.ErrorMobileNo
                            </b>
                        </td>
                    </tr>
                    <tr>
                        <td>
                            身份证号码：
                        </td>
                        <td>
                            @Html.TextBoxFor(a => a.IDCard)
                        </td>
                    </tr>
                    <tr>
                        <td>
                            &nbspE-mail&nbsp：
                        </td>
                        <td>@Html.TextBoxFor(a => a.EMail)
                        </td>
                    </tr>
                    <tr>
                        <td>
                            &nbsp区&nbsp&nbsp域&nbsp：
                        </td>
                        <td>
                            @Html.DropDownList("ProvinceID", PageHelper.ProvinceSelector(Model.ProvinceID))
                            @Html.DropDownList("CityID", PageHelper.CitySelector(Model.CityID, Model.ProvinceID))
                            @Html.DropDownList("AreaID", PageHelper.AreaSelector(Model.AreaID, Model.CityID))
                        </td>
                    </tr>
                    <tr>
                        <td>
                            详细地址：
                        </td>
                        <td>@Html.TextBoxFor(a => a.Address, new { style = "width:600px;" })
                        </td>
                    </tr>
                    <tr>
                        <td>
                            &nbsp邮&nbsp&nbsp编&nbsp：
                        </td>
                        <td>@Html.TextBoxFor(a => a.PostalCode, new { style = "width:100px" })
                        </td>
                    </tr>
                    <tr style="h">
                        <td>
                            &nbsp备&nbsp&nbsp注&nbsp：
                        </td>
                        <td>
                            @Html.TextAreaFor(a => a.Remarks, new { style = "width:100%;" })
                        </td>
                    </tr>
                    <tr>
                        <td colspan="2">
                            <br />
                            <strong>服务</strong>
                            <hr />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            客服人员：
                        </td>
                        <td>
                            @Html.HiddenFor(t => t.CustomerServiceID)
                            @Html.TextBoxFor(t => t.CustomerServiceIDName)
                        </td>
                    </tr>
                    <tr>
                        <td>
                            业&nbsp务&nbsp员：
                        </td>
                        <td>
                            @Html.HiddenFor(t => t.SalesmanID)
                            @Html.TextBoxFor(t => t.SalesmanIDName)
                        </td>
                    </tr>
            </table>
        </div>
        <div class="BottomBtn" style="padding-left: 100px;">
            <button class="blue" type="submit">
                <span>保存</span></button>
        </div>
    </div>
    </form>
</body>
</html>
